<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <title>Title</title>
<!--  <link rel="stylesheet" href="stylesheets/reset.css">-->
  <link rel="stylesheet" href="stylesheets/index.css">
  <style>
    .red {
      color: red;
    }
    .blue {
      color: blue;
    }
  </style>
</head>
<body>

<div id="app">
  <h1 v-if="show">{{ msg }}</h1>
  <input type="text" v-model="msg">
  <button v-on:click="show = !show">toggle</button>
<!--  <h1>{{ cc }}</h1>-->
</div>

<script src="js/vue.js"></script>
<script>
  // M(model数据层)V(view视图)VM
  // v-model 双向数据绑定
  // MVC
  // MV
  // template 模板  虚拟DOM
  // ### beforeCreate
  // let h1 = document.createElement('h1')
  // h1.textContent = msg
  // ### created
  // ### beforeMount
  // app.append(h1)
  // ### mounted
  //
  // ### beforeUpdate
  // msg
  // h1.textContent = msg
  // ### updated

  let app = new Vue({
    // el: '#app',
    data: { // 响应式系统 Object.defineProperty()
      msg: 'hello vue',
      show: true
    },
    beforeDestroy() {
      console.log('beforeDestroy')
    },
    destroyed() {
      console.log('destroyed')
    },
    mounted() {
      console.log('mounted')
    },
    beforeMount() {
      console.log('beforeMount')
    },
    beforeUpdate() {
      console.log('beforeUpdate')
    },
    updated() {
      console.log('updated')
    },
    beforeCreate() {
      console.log('beforeCreate')
    },
    created() {
      console.log('created')
      // this.msg = '我在created里修改了'
      // this.cc = 'cc'
    }
  }).$mount('#app')

</script>
</body>
</html>
